package Exercise;

import java.util.concurrent.locks.LockSupport;

public class Demo01_park_unpark的使用 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                System.out.println("running-before...");

                // 暂停当前线程
                LockSupport.park();

                System.out.println("running-after...");
            }
        };

        t1.start();

        Thread.sleep(1000);

        // 解除t1线程的暂停
        LockSupport.unpark(t1);
    }
}
